// Copyright (c) 2019 Presto Labs Pte. Ltd.
// Author: linchuan

#include "coin2/exchange/bitmex/symbology/currency.h"

#include <gtest/gtest.h>

TEST(BitmexCurrency, constructor) {
  using namespace coin2::exchange::bitmex::symbology;
  using coin2::exchange::base::market::ExchangeType;
  using coin2::exchange::base::market::MarketType;

  int64_t resolve_ts = 1572502253 * 1e9;

  BitmexCurrency usdt("USD");
  EXPECT_EQ(usdt.currency(), "USD");
  EXPECT_EQ(usdt.native_currency(MarketType::Spot), "USD");
  EXPECT_EQ(usdt.rep_currency(), "USD");
  EXPECT_EQ(usdt.exchange(), ExchangeType::Bitmex);

  auto btc1 = BitmexCurrency::FromNativeStr("XBT", resolve_ts);
  EXPECT_EQ(btc1.currency(), "BTC");
  EXPECT_EQ(btc1.native_currency(MarketType::Spot), "XBT");
  EXPECT_EQ(btc1.native_currency(MarketType::Futures), "XBT");
  EXPECT_EQ(btc1.exchange(), ExchangeType::Bitmex);

  auto btc2 = BitmexCurrency::FromNativeStr("XBT", resolve_ts);
  auto btc3 = BitmexCurrency::FromNormStr("BTC", resolve_ts);
  auto btc4 = BitmexCurrency::FromStr("BTC", resolve_ts);
  EXPECT_EQ(btc2, btc1);
  EXPECT_EQ(btc3, btc1);
  EXPECT_EQ(btc4, btc1);

  auto btc = BitmexCurrency::FromStr("BTC", resolve_ts);
  EXPECT_EQ(btc.currency(), "BTC");
  EXPECT_EQ(btc.native_currency(MarketType::Spot), "XBT");

  auto bch = BitmexCurrency::FromStr("BCH", resolve_ts);
  EXPECT_EQ(bch.currency(), "BCHABC");
  EXPECT_EQ(bch.native_currency(MarketType::Spot), "BCH");
}
